package model;

import java.util.Calendar;
import java.util.Date;

/**
 * @author Manseer Marcel  
 * @author Plavsic Maja
 * @author Pretsch Paul
 */
public class Tools {
	
	/**
	 * truncates the time from a given date
	 * 
	 * @param date
	 * @return {@link java.util.Date Date}
	 */
	public static final Date TruncateTime(Date date) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.set(Calendar.HOUR_OF_DAY, 0);
		c.set(Calendar.MINUTE, 0);
		c.set(Calendar.SECOND, 0);
		c.set(Calendar.MILLISECOND, 0);		
		return c.getTime();
	}
	
	/**
	 * increments the day of a date by a given amount
	 * 
	 * @param date
	 * @param amount
	 * @return {@link java.util.Date Date}
	 */
	public static final Date IncDay(Date date, int amount)
	{
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.DATE, amount);
		return c.getTime();
	}

	/**
	 * formats a date to be used with a {@link twitter4j.Query Query}
	 * 
	 * @param date
	 * @return {@link java.lang.String String}
	 */
	public static String FormattedTwitterDate(Date date) {
		return new java.sql.Date(date.getTime()).toString();
	}

}
